package com.haoxi.gateway.cngpmsg;
public class CNGPDeliverRespMessage extends CNGPMessage {

    private StringBuffer strBuf;

    public CNGPDeliverRespMessage(byte msgId[], int congestionState)
            throws IllegalArgumentException {
        if (msgId.length > 10)
            throw new IllegalArgumentException(
                    "The parameter of response message for answering the deliver message sent by SMC is wrong:msg_Idlength is larger than 10");
        if (congestionState < 0 || congestionState > 255) {
            throw new IllegalArgumentException(
                    "The parameter of response message for answering the deliver message sent by SMC is wrong:congestionState less than 0 or larger than 255.");
        } else {
            int len = 31;
            buf = new byte[31];
            setMsgLength(len);
            setRequestId(0x80000003);
            System.arraycopy(msgId, 0, buf, 16, msgId.length);
            buf[30] = (byte) congestionState;
            strBuf = new StringBuffer(100);
            strBuf.append(",MsgId=").append(msgId);
            strBuf.append(",congestionState=").append(congestionState);   
        }
    }

    public String toString() {
        StringBuffer outStr = new StringBuffer();
        outStr.append("CNGPDeliverRespMessage:");
        strBuf.append("PacketLength=").append(getMsgLength());
        strBuf.append(",RequestID=").append(getRequestId());
        strBuf.append(",Status=").append(getStatus());
        outStr.append(",SequenceId=").append(getSequenceId());
        if (strBuf != null)
            outStr.append(strBuf.toString());
        return outStr.toString();
    }
}
